package three;


class PetShop {
	 private Pet[] pets;
	 private int foot;
	 private Cat cats[];
	 private Dog dogs[];
	 public PetShop(int len){
		 if(len>0){
			 this.pets=new Pet[len];
		 }else{
			 this.pets=new Pet[1];
		 }
	 }
	 public Cat[] getCats(){
			return cats ;
		}
		public void setCats(Cat[] cats){
			this.cats=cats;
		}
		public Dog[] getDogs(){
			return dogs ;
		}
		public void setDogs(Dog[] dogs){
			this.dogs=dogs;
		}
	public boolean add(Pet pet){
		 if(this.foot<this.pets.length){
			 this.pets[this.foot]=pet;
			 this.foot++;
			 return true;
		 }else{
			 return false;
		 }
	 }
	 public Pet[] search(String a){
		 Pet p[]=null;
		 int count=0;
		 for(int i=0;i<this.pets.length;i++){
			 if(this.pets[i]!=null){
				 if(this.pets[i].getNo().indexOf(a)!=-1){	
					 count++;
				 }
				
			 }
		 }
		 p=new Pet[count];
		 int f=0;
		 for(int i=0;i<this.pets.length;i++){
			 if(this.pets[i]!=null){
				 if(this.pets[i].getNo().indexOf(a)!=-1){
					 p[f]=this.pets[i];		 
					 f++;		 
				 }
			 }
		 }	  
		 return p;
		 
	 }	
	 
	 }
